<template>
  <el-card class="content small-padding-card">
    <text-tree
      :tree="treeData"
      :default-expanded-keys="defaultExpandKeys"
    ></text-tree>
  </el-card>
  <!-- <manual-monitor></manual-monitor> -->
</template>

<script>
import Axios from "axios";
import TextTree from "~/components/TextTree";
import DryBeach from "./manual-monitoring/DryBeach";
import ReservoirWaterLevel from "./manual-monitoring/ReservoirWaterLevel";
import OuterSlopeRatio from "./manual-monitoring/OuterSlopeRatio";
// 表面位移  北斗站
import LnternalDisplacement from "./manual-monitoring/LnternalDisplacement";
// 浸润线
import PhreaticLine from "./manual-monitoring/PhreaticLine";

export default {
  name: "ManualMonitoring",
  components: {
    TextTree,
  },
  props: {
    keys: {
      type: String,
      default: "test",
      require: false,
    },
  },
  data() {
    return {
      defaultExpandAll:false,
      treeData: null,
    };
  },
  methods: {
    async initData() {
      let temp;
      await Axios({
        url:
          "/leftMenuTree/getManualMonitorTree/" +
          `${sessionStorage.getItem("unitId")}`,
      }).then((res) => {
        console.log(res);
        if (res.data.parameter.tailingPondList !== null) {
          let list = res.data.parameter.tailingPondList;
          for (let i = 0; i < list.length; i++) {
            for (let key in list[i])
              key === "tailingName"
                ? (list[i].label = list[i][key]) &&
                  (list[i].uu = require("../../assets/icon/money.svg"))
                : null;
            if (list[i].monitorTypeList !== null) {
              for (let k = 0; k < list[i].monitorTypeList.length; k++) {
                for (let key in list[i].monitorTypeList[k]) {
                  key === "name"
                    ? (list[i].monitorTypeList[k].label =
                        list[i].monitorTypeList[k][key])
                    : null;
                  list[i].monitorTypeList[
                    k
                  ].uu = require("../../assets/icon/file.svg");
                }
                if (list[i].monitorTypeList[k].monitorPointList !== null) {
                  for (
                    let j = 0;
                    j < list[i].monitorTypeList[k].monitorPointList.length;
                    j++
                  ) {
                    for (let key in list[i].monitorTypeList[k].monitorPointList[
                      j
                    ]) {
                      key === "name"
                        ? (list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].label =
                            list[i].monitorTypeList[k].monitorPointList[j].name)
                        : null;
                      switch (list[i].monitorTypeList[k].id) {
                        case 1:
                          list[i].monitorTypeList[k].monitorPointList[
                            k
                          ].component = DryBeach;
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].uu = require("../../assets/icon/gt.svg");
                          break;
                        case 2:
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].component = ReservoirWaterLevel;
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].uu = require("../../assets/icon/ksw.svg");
                          break;
                        case 3:
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].component = LnternalDisplacement;
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].uu = require("../../assets/icon/bmwy.svg");
                          break;
                        case 5:
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].component = PhreaticLine;
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].uu = require("../../assets/icon/jrx.svg");
                          break;
                        case 8:
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].component = OuterSlopeRatio;
                          list[i].monitorTypeList[k].monitorPointList[
                            j
                          ].uu = require("../../assets/icon/gtpb.svg");
                          break;
                      }
                    }
                  }
                  list[i].monitorTypeList[k].children =
                    list[i].monitorTypeList[k].monitorPointList;
                }
                list[i].children = list[i].monitorTypeList;
              }
            }
          }
          temp = list;
        }
      });
      this.treeData = temp;
      // if (this.treeData[0].children.length>0) {

      // }

      // console.log("人工监测",this.treeData);
      return temp;
    },
  },
  created() {
    this.initData().then((res) => {});
  },
};
</script>

<style scoped>
.content {
  margin-top: 8px;
  display: flex;
}
</style>
<style>
.small-padding-card > .el-card__body {
  padding: 3px 8px;
}
</style>
